package com.hankol.community.adapter

import android.text.TextPaint
import android.widget.TextView
import com.baselibrary.utils.GlideUtils
import com.baselibrary.utils.ImageUtils
import com.baselibrary.utils.NumberUtils
import com.baselibrary.utils.ScreenUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.hankol.community.R
import com.hankol.community.bean.HotBannerData


/**
 *@author:hanke
 *2022/3/30
 *desc:
 */
class DiscoverTopicAdapter : BaseQuickAdapter<HotBannerData.DataDTO.HotTagsDTO, BaseViewHolder>(R.layout.item_discover_topic) {

    override fun convert(helper: BaseViewHolder, item: HotBannerData.DataDTO.HotTagsDTO) {
        val text = "# " + item.name
        helper.setText(R.id.tv_topic_name, text)
        val number = NumberUtils.formatBigNum(item.virtualMember.plus(item.browseNum))
        helper.setText(R.id.tv_topic_join_number, number + "参加")

        GlideUtils.loadImg_228(mContext, item.cover, helper.getView(R.id.iv_topic_cover))
        val textPaint: TextPaint = helper.getView<TextView>(R.id.tv_topic_name).paint
        val textPaintWidth: Float = textPaint.measureText(text)
        ImageUtils.addMask(textPaintWidth.toInt() + ScreenUtils.dpToPx(40), helper.getView(R.id.iv_topic_cover), helper.getView(R.id.rci_mask), helper.getView(R.id.tv_topic_name), helper.getView(R.id.tv_topic_join_number))
        textPaint.isFakeBoldText = true
    }
}